using BasicData.API.Dtos;
using BasicData.ErrorCode;
using MediatR;
using System.ComponentModel.DataAnnotations;

namespace BasicData.API.Application.Command
{
    /// <summary>
    /// 用户注册命令
    /// </summary>
    public class RegisterUserCommand : IRequest<APIResult<UserDTO>>
    {
        /// <summary>
        /// 用户名
        /// </summary>
        [Required(ErrorMessage = "用户名不能为空")]
        [StringLength(50, MinimumLength = 3, ErrorMessage = "用户名长度必须在3-50个字符之间")]
        [RegularExpression(@"^[a-zA-Z0-9_]+$", ErrorMessage = "用户名只能包含字母、数字和下划线")]
        public string Username { get; set; } = null!;

        /// <summary>
        /// 密码
        /// </summary>
        [Required(ErrorMessage = "密码不能为空")]
        [StringLength(100, MinimumLength = 6, ErrorMessage = "密码长度必须在6-100个字符之间")]
        public string Password { get; set; } = null!;

        /// <summary>
        /// 确认密码
        /// </summary>
        [Required(ErrorMessage = "确认密码不能为空")]
        [Compare("Password", ErrorMessage = "两次输入的密码不一致")]
        public string ConfirmPassword { get; set; } = null!;

        /// <summary>
        /// 真实姓名
        /// </summary>
        [StringLength(50, ErrorMessage = "真实姓名长度不能超过50个字符")]
        public string? RealName { get; set; }

        /// <summary>
        /// 电子邮箱
        /// </summary>
        [EmailAddress(ErrorMessage = "电子邮箱格式不正确")]
        [StringLength(100, ErrorMessage = "电子邮箱长度不能超过100个字符")]
        public string? Email { get; set; }

        /// <summary>
        /// 手机号码
        /// </summary>
        [RegularExpression(@"^1[3-9]\d{9}$", ErrorMessage = "手机号码格式不正确")]
        public string? Phone { get; set; }

        /// <summary>
        /// 角色ID（默认为普通用户角色）
        /// </summary>
        public int RoleId { get; set; } = 2; // 假设2是普通用户角色ID
        
        /// <summary>
        /// 验证码ID
        /// </summary>
        [Required(ErrorMessage = "验证码ID不能为空")]
        public string CaptchaId { get; set; } = null!;
        
        /// <summary>
        /// 验证码
        /// </summary>
        [Required(ErrorMessage = "验证码不能为空")]
        public string CaptchaCode { get; set; } = null!;
    }
} 